<template>
  <div>
    <el-card class="top-card">
      <div slot="header" style="font-weight: bold; color: black;">生日查询</div>
      <el-select v-model="selectedMonth" placeholder="请选择月份" @change="getBirthMonthInfo">
        <el-option v-for="month in months" :key="month" :label="month + '月'" :value="month" />
      </el-select>
    </el-card>

    <el-card class="bottom-card">
      <div slot="header" style="font-weight: bold; color: black;">员工生日列表</div>
      <el-table :data="employeeList" style="width: 100%">
        <el-table-column label="id号" align="center" prop="userId" />
        <el-table-column label="员工名称" align="center" prop="name" />
        <el-table-column label="员工生日" align="center">
          <template slot-scope="scope">
            {{ scope.row.birthday }}
          </template>
        </el-table-column>
        <el-table-column label="工号" align="center" prop="empNumber" />
        <el-table-column label="用户性别" align="center" prop="sex">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.sex" />
          </template>
        </el-table-column>
        <el-table-column label="手机号码" align="center" prop="phoneNumber" />
        <el-table-column label="地区" align="center" prop="region" />
        <el-table-column label="入职时间" align="center" prop="date" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.date, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="入职类型" align="center" prop="typeOfEmployment">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.type_of_employment" :value="scope.row.typeOfEmployment" />
          </template>
        </el-table-column>
        <el-table-column label="人员类型" align="center" prop="typeOfMen">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.type_of_men" :value="scope.row.typeOfMen" />
          </template>
        </el-table-column>
        <el-table-column label="爱好特长" align="center" prop="hobby" />
        <el-table-column label="寝室号" align="center" prop="dormitory" />
        <el-table-column label="其他" align="center" prop="other" />
      </el-table>
    </el-card>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { getBirthMonthInfo } from "@/api/Empment/selectbybitrhday";

export default {
  name: "birthday",
  dicts: ['marital_status', 'type_of_employment', 'type_of_men', 'sys_user_sex'],
  data() {
    return {
      loading: true,
      ids: [],
      single: true,
      deptName: undefined,
      deptOptions: undefined,
      multiple: true,
      showSearch: true,
      total: 0,
      informationList: [],
      postOptions: [],
      roleOptions: [],
      title: "",
      open: false,

      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
        name: null,
        deptId: null,
        empNumber: null,
        sex: null,
        idCard: null,
        idNumberRegion: null,
        phoneNumber: null,
        region: null,
        contractDate: null,
        contractLong: null,
        date: null,
        typeOfEmployment: null,
        typeOfMen: null,
        maritalStatus: null,
        politicalLandscape: null,
        address: null,
        highEducationalLevel: null,
        school: null,
        major: null,
        nation: null,
        emergencyContact: null,
        emergencyContactPhone: null,
        firstDegree: null,
        secondDegree: null,
        typeEducation: null,
        bank: null,
        bankAccountNumber: null,
        hobby: null,
        dormitoryNeed: null,
        dormitory: null,
        birthday: null,
        other: null,
        Reserved1: null,
        Reserved2: null,
        Reserved3: null,
        Reserved4: null,
        Reserved5: null,
        Reserved6: null,
        Reserved7: null,
        Reserved8: null
      },

      selectedMonth: new Date().getMonth() + 1,
      months: Array.from({ length: 12 }, (_, i) => i + 1),
      employeeList: []
    };
  },
  methods: {
    getList() {
      this.getBirthMonthInfo();
    },
    async getBirthMonthInfo() {
      if (this.selectedMonth) {
        const response = await getBirthMonthInfo(this.selectedMonth, this.queryParams.pageNum, this.queryParams.pageSize);
        this.employeeList = response.rows;
        this.total = response.total;
      } else {
        this.employeeList = [];
        this.total = 0;
      }
    }
  },
  mounted() {
    this.getBirthMonthInfo();
  }
};
</script>
